﻿using System;
using System.Collections.Generic;
#if DEBUG
using System.Diagnostics;
#endif // #if DEBUG
using System.Linq;
using System.Web;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;

using FRL.DebtChased.Repository;
using FRL.DebtChased.Repository.PartModels;

namespace FRL.DebtChased.Website.FinanceParts
{

	/// <summary>
	/// Declaration of FinInboxTable class
	/// </summary>
	public class FinInboxTable : BaseWebPart
	{

		/////////////////////////////////////////////////////////////
		// Attributes

		/////////////////////////////////////////////////////////////
		// Construction

		public FinInboxTable()
			:base("Inbox")
		{

		}

		/////////////////////////////////////////////////////////////
		// Implementation

		protected override int ContentWidth
		{
			get { return 260; }
		}

		protected override int ContentHeight
		{
			get { return 0; }
		}

		protected override string GrivViewSkinId
		{
			get { return "InboxGridView"; }
		}

		protected override void _fillContent(System.Web.UI.HtmlTextWriter w, GridView gridView)
		{

			// Add to html
			gridView.RenderControl(w);

		}

		protected override void _loadModel()
		{

			// Get repository
			DebtChasedEntities ent = base._getEnt();

			// Load the model
			m_model = new InboxModel(ent);

		}

		protected override void _bindGrid(GridView gridView)
		{

			// Shortcuts
			if (gridView.DataSource != null)
				return;
			if (m_model == null)
				return;

			// Set up grid
			gridView.DataKeyNames = new string[1] { "InboxId" };
			gridView.DataSource = (m_model as InboxModel).m_data;
			gridView.DataBind();

		}

		protected override void _processCommand(string strCommandName, int iId)
		{

			// Open comms item
			HttpContext.Current.Response.Redirect("~/Finance/CommsItem.aspx");

		}

	}

}